﻿﻿using System;
using System.Xml;
using StarTrek.Ship;
using StarTrek.World;

namespace StarTrek.Space
{
    public class SpaceUnit:iSpaceItem
    {
        private Quadrant parent;
        private Guid id;
        private iShip PresentVessel;

        public SpaceUnit()
        {
            id = Guid.NewGuid();
        }

        #region iSpaceItem Members

        public Quadrant Parent
        {
            get
            {
                return parent;
            }
            set
            {
                parent = value;
            }
        }

        public bool isShipDocked()
        {
            return false; //This is empty space; cannot dock here
        }

        public iShip DockedShip
        {
            get
            {
                return null; //There is not a ship docked here
            }
            set
            {
                ;//Docking a ship here does nothing
            }
        }
        public iShip PresentShip
        {
            get
            {
                return PresentVessel;
            }
            set
            {
                PresentVessel = value;
            }
        }

        public SpaceUnitInfo BuildInfo()
        {
            throw new NotImplementedException();
        }

        public float CalculateDistance(iSpaceItem Target)
        {
            if (parent.Contains(Target))
                return parent.CalculateDistance(this, Target);
            else
                return Parent.Parent.CalculateDistance(this, Target);
        }

        public float TerrainPenalty
        {
            get { return 0; }
        }

        public Guid SectorIdentifier
        {
            get { return id; }
        }
        public iSpaceItem FromXml(XmlNode val)
        {
            throw new NotImplementedException();
        }
        public override string ToString()
        {
            return "Void Space";
        }
        public bool isDockable
        {
            get { return false; }
        }

        public bool isTravelable
        {
            get { return true; }
        }
        #endregion
    }
}
